package com.sword.www.designPattern.prototype;

import java.util.HashMap;
import java.util.Map;

/**
 * 原型管理器
 * @author linmeng
 * @version 1.0
 * @date 2021年11月11日 22:54
 */
public class PrototypeManager {

    private static Map<String,Prototype> manager = new HashMap<>();

    private PrototypeManager() {
    }

    public static void addPrototype(String prototypeId,Prototype prototype){
        manager.put(prototypeId,prototype);
    }
    public static void removePrototype(String prototypeId){
        manager.remove(prototypeId);
    }

    public static Prototype getPrototype(String prototypeId){
        return manager.get(prototypeId);
    }

    public static void main(String[] args) {
        ConcretePrototype concretePrototype = new ConcretePrototype();
        concretePrototype.setType("1");
        PrototypeManager.addPrototype("1",concretePrototype);

    }
}
